package jzoffer.jz09;

import java.util.Stack;

class CQueue {
    Stack<Integer> stack1 = new Stack<>();
    Stack<Integer> stack2 = new Stack<>();

    public CQueue() {

    }

    public void appendTail(int value) {
        stack1.push(value);
    }

    public int deleteHead() {
        boolean flag = false;
        //从1->2再pop
        while (!stack1.empty()) {
            stack2.push(stack1.pop());
        }
        //pop
        int res = 0;
        if (!stack2.empty()) {
            flag = true;
            res = stack2.pop();
        }
        //从2->1
        while (!stack2.empty()) {
            stack1.push(stack2.pop());
        }
        return flag ? res : -1;
    }

}
